import React, {Suspense} from 'react';
import { BrowserRouter, Switch } from 'react-router-dom';
import AuthRoute from './components/AuthRoute';
import { routes } from './routes';

const Router = () => {
	return (
		<BrowserRouter>
            <Suspense fallback={'加载中...'}>{/*加载过程中可以使用组件替代文本内容实现加载动画效果*/}
                <Switch>
                    {
                        routes.map((route,index) => {
                            return <AuthRoute key={index} {...route} />
                        })
                    }
                </Switch>
            </Suspense>
		</BrowserRouter>
	)
}

export default Router;